//
//  M80AttributedLabel.h
//  M80AttributedLabel
//
//  Created by amao on 13-9-1.
//  Copyright (c) 2013年 www.xiangwangfeng.com. All rights reserved.
//

#import <UIKit/UIKit.h>
#import <CoreText/CoreText.h>
#import "M80AttributedLabelDefines.h"
#import "NSMutableAttributedString+M80.h"
#import "M80AttributedLabelURL.h"

@class M80AttributedLabelURL;

@protocol M80AttributedLabelDelegate <NSObject>

@optional
- (void)m80AttributedLabel:(M80AttributedLabel *)label
             clickedOnLink:(M80AttributedLabelURL *)linkInfo;

- (void)m80AttributedLabelClick;

@end

@interface M80AttributedLabel : UIView
@property (nonatomic,weak)    id<M80AttributedLabelDelegate> delegate;
@property (nonatomic,strong)    UIFont *font;                   //字体
@property (nonatomic,strong)    UIColor *textColor;             //文字颜色
@property (nonatomic,strong)    UIColor *highlightColor;        //链接点击时背景高亮色
@property (nonatomic,strong)    UIColor *linkColor;             //链接色
@property (nonatomic,assign)    BOOL    underLineForLink;       //链接是否带下划线
@property (nonatomic,assign)    BOOL    autoDetectLinks;        //自动检测
@property (nonatomic,assign)    NSInteger   numberOfLines;      //行数
@property (nonatomic,assign)    CTTextAlignment textAlignment;  //文字排版样式
@property (nonatomic,assign)    CTLineBreakMode lineBreakMode;  //LineBreakMode
@property (nonatomic,assign)    CGFloat lineSpacing;            //行间距
@property (nonatomic,assign)    CGFloat paragraphSpacing;       //段间距
@property (nonatomic,strong)    NSMutableString *labelText;     //内容
@property (nonatomic,assign)    int fromType;                   //来源 0-聊天界面 1-我的界面

//普通文本
- (void)setText:(NSString *)text;
- (void)appendText: (NSString *)text;

/// 这里是针对文字的颜色进行的定制的添加文本
- (void)appendText:(NSString *)text textColor:(UIColor *)color;


//属性文本
- (void)setAttributedText:(NSAttributedString *)attributedText;
- (void)appendAttributedText: (NSAttributedString *)attributedText;

//图片
- (void)appendImage: (UIImage *)image;
- (void)appendImage: (UIImage *)image
            maxSize: (CGSize)maxSize;
- (void)appendImage: (UIImage *)image
            maxSize: (CGSize)maxSize
             margin: (UIEdgeInsets)margin;
- (void)appendImage: (UIImage *)image
            maxSize: (CGSize)maxSize
             margin: (UIEdgeInsets)margin
          alignment: (M80ImageAlignment)alignment;

//UI控件
- (void)appendView: (UIView *)view;
- (void)appendView: (UIView *)view
            margin: (UIEdgeInsets)margin;
- (void)appendView: (UIView *)view
            margin: (UIEdgeInsets)margin
         alignment: (M80ImageAlignment)alignment;


//添加自定义链接
- (void)addCustomLink: (id)linkData
             forRange: (NSRange)range
             linkType: (int)linkType;

- (void)addCustomLink: (id)linkData
             forRange: (NSRange)range
            linkColor: (UIColor *)color
             linkType: (int)linkType;


//大小
- (CGSize)sizeThatFits:(CGSize)size;

//设置全局的自定义Link检测Block(详见M80AttributedLabelURL)
+ (void)setCustomDetectMethod:(M80CustomDetectLinkBlock)block;

#pragma mark - 正则匹配电话号码，网址链接，Email地址
+ (NSArray *)addRexArr:(NSString *)text;


#pragma mark - label   user name type
@property(nonatomic,copy)NSString *label_user;
@property(nonatomic,copy)NSString *label_name;
@property(nonatomic)int label_type;


@end
